package net.sf.jhighlighter.ui;

import javax.swing.JScrollPane;
import javax.swing.text.JTextComponent;

/**
 *
 * @author Paul Kenny
 */
public class FScrollPane extends JScrollPane {

    JTextComponent textArea = null;
    // Line numbering things
    LineNumbering lineNumbering;
    boolean lineNumberingEnabled = true;
    // Line highlighting things
    LineHighlighter lineHighlighter;
    boolean lineHighlightingEnabled = true;

    public FScrollPane(JTextComponent textArea) {
        super(textArea);
        this.textArea = textArea;
        lineNumbering = new LineNumbering(this.textArea);

        lineHighlighter = new LineHighlighter(this.textArea);

        setRowHeaderView(lineNumbering);
    }

    public void setLineNumberingEnabled(boolean arg) {
        if(arg) {
            setRowHeaderView(lineNumbering);
            lineNumberingEnabled = true;
        } else {
            setRowHeaderView(null);
            lineNumberingEnabled = false;
        }
    }

    public boolean getLineNumberingEnabled() {
        return lineNumberingEnabled;
    }

    public void setLineHighlightingEnabled(boolean arg) {
        if(arg) {
            lineHighlighter.setHighlightingEnabled(arg);
            lineHighlightingEnabled = true;
        } else {
            lineHighlighter.setHighlightingEnabled(arg);
            lineHighlightingEnabled = false;
        }
    }

    public boolean getLineHighlightingEnabled() {
        return lineHighlightingEnabled;
    }
}
